<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>ySocial - Sign In</title>
    <link href="CSS/login.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="JS/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="JS/soapclient.js"></script>
    <script type="text/javascript" src="JS/md5.js"></script>
    <script type="text/javascript">
        function getlogin() {
            var pl = new SOAPClientParameters();
            pl.add("email", document.login.username.value.trim());
            pl.add("password", hex_md5(document.login.password.value.trim()));
            SOAPClient.invoke("/m/", "Login", pl, true, callback_login);
        }

        function callback_login(r) {;
            if (r == null) {
                document.getElementById('error').innerHTML = 'Email and password does not match. Please try again';
            }
            
            if (r["email"] != "") {
                console.log(r);
                if (document.login.password.value === 'ysocial') {;
                    window.location = '/Home/';
                    window.location.reload(true);
                }
                else{
                    window.location.replace("Home");
                }
            }
        }
    </script>
</head>
<body>
    <div id="main-container">
        <div id="main">
            <h1><a href="#"><img alt="ySocial" src="Images/ySocial.png"></a></h1>
            <h2>Sign in</h2>
            <div id="form-oldschool">
                <form name="login" accept-charset="UTF-8" action="" class="gen-form" method="post" onsubmit="getlogin();return false;">
                    <div style="margin:0;padding:0;display:inline">
                        <input name="utf8" type="hidden" value="?"><input name="authenticity_token" type="hidden" value= "">
                    </div>
                    <fieldset>
                        <label for="login">Username or Email</label>
                        <input class="text-input" id="id_username" name="username" tabindex="1" type="text">
                    </fieldset>
                    <fieldset style="margin-bottom: 10px;">
                        <label for="password">Password <a href="#">Forgot?</a></label> 
                        <input class="text-input" id="id_password" name="password" tabindex="2" type="password">
                    </fieldset>
                    <div id="error" style="color: whitesmoke; font-family: Calibri; font-size: 11pt;padding-bottom: 5px;">&nbsp;</div>
                    <input class="button" tabindex="3" type="submit" value="Sign In">
                </form>
            </div>
            <div class="sign-connections">
                <p>One-click sign in to ySocial if your account is connected
                to Twitter. We'll walk you through connecting it if it
                isn't.</p>
            </div>
            <p class="sign-notamember">Not a member? <a href="/signup">Sign up now</a></p>
        </div>
    </div>
</body>
</html>